package com.springboot.lock.web;

import com.springboot.lock.lock_redis.anno.RedisLock;
import com.springboot.lock.lock_zk.ZkLock;
import com.springboot.lock.service.LockTestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: TongRui乀
 * @Date: 2020-08-06 10:26
 * @description：
 */
@RestController
public class LockController {

    @Autowired
    private LockTestService lockTestService;

//    @RedisLock(columns = {"p1"}, waitTime = 3000)
    @ZkLock(columns = {"p1"}, waitTime = 3000)
    @GetMapping("lock")
    public String test(String p1){

        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        lockTestService.test(p1);

        return "SUCCESS";
    }

}
